package cn.yj.cgs.dba.mapper;

import cn.yj.annotation.pagehelper.annotation.StartPage;
import cn.yj.annotation.pagehelper.page.Page;
import cn.yj.cgs.dba.entity.Product;
import cn.yj.cgs.dba.entity.ProductType;
import cn.yj.cgs.dba.entity.vo.ProductVo;
import cn.yj.common.NameValue;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.Date;
import java.util.List;
import java.util.Map;

/**
 * @author 永健
 * @since 2021-06-15 14:45
 */
public interface ProductMapper extends BaseMapper<Product> {

    @StartPage
    List<ProductVo> pageList(@Param("map") Map<String,Object> params, Page<ProductVo> page);


    @StartPage
    List<ProductType> typePageList(@Param("map") Map<String, Object> params, Page<ProductType> page);

    List<NameValue> typeList();

    @Delete("delete from tb_product_type where type_no =#{typeNo}")
    boolean deleteTypeByNo(String typeNo);

    @Insert("insert into tb_product_type(name,type_no,create_time) values(#{name},#{typeNo},now()) ")
    boolean insertType(ProductType productType);

    boolean updateTypeById(ProductType productType);

    @Select("select * from tb_product_type where name=#{typeName}")
    ProductType selectByName(String typeName);

    long countByTypeNo(@Param("typeNos") List<String> typeNo);

    Product selectByNoForUpdate(String productNo);

    ProductVo selectByNo(String productNo);

    long countByDateRange(@Param("startTime") Date startDate,@Param("endTime") Date endDate);

    long countByDate(Date date);

    long countAll();

    List<NameValue> pieChart();

    @Select("select * from tb_product_type")
    List<ProductType> selectListType();
}
